﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<WebMvc.Models.Ticket>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Tickets
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Tickets</h2>
    
    <%= Html.ActionLink("Crear Ticket", "Crear", "Tickets") %>
    
    <% if (Model.Any())
       { %>
       <table style="margin-top: 10px;">
           <thead>
               <tr>
                   <th>#</th>
                   <th>Nombre</th>
                   <th>Estado</th>
                   <th>Inicio</th>
                   <th>Cierre</th>
                   <th>Sala Activa</th>
                   <th>Acciones</th>
               </tr>
           </thead>
           <tbody>
               <% foreach (var ticket in Model)
                  { %>
                  <tr>
                      <td><%= ticket.Id %></td>
                      <td><%= ticket.Nombre %></td>
                      <td><%= ticket.Estado %></td>
                      <td><%= ticket.FechaInicio.ToString() %></td>
                      <td><%= ticket.FechaFin.HasValue ? ticket.FechaFin.Value.ToString() : string.Empty%></td>
                      <td><%= ticket.UsuariosActivosEnSala > 0 ? string.Format("Si ({0} usuarios)", ticket.UsuariosActivosEnSala) : "No" %></td>
                      <td>
                          <%= Html.ActionLink("Detalles", "Ver", "Tickets", new { id = ticket.Id }, null) %>
                          <% if (!ticket.FechaFin.HasValue)
                             { %> <%= Html.ActionLink("Cerrar", "Cerrar", "Tickets", new {id = ticket.Id}, null) %> <% } %>
                          <%= Html.ActionLink("Eliminar", "Eliminar", "Tickets", new { id = ticket.Id }, null) %>
                      </td>
                  </tr>
               <% } %>
           </tbody>
       </table>
       
    <% }
       else
       { %>
       <p>No hay tickets ingresados.</p>    
    <% } %>
    

</asp:Content>



